<!DOCTYPE HTML>
<html>
<head>
<title>窗口遮蔽(卷起窗口到标题栏) - 脚本示例 | AutoHotkey</title>
<meta name="description" content="The window shading script reduces a window to its title bar and then back to its original size by pressing a single hotkey." />
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>窗口遮蔽(卷起窗口到标题栏) <span class="headnote">Rajat 所写</span></h1>

<p>此脚本通过单个热键实现裁减窗口到它的标题栏, 再次使用热键后恢复为原始大小. 这种方式可以裁减任意数目的窗口(脚本会记住每个窗口原来的大小). 如果脚本由于任何原因退出了, 那么所有 "卷起" 的窗口会自动恢复为它们原来的高度.
</p>
<p><a href="WindowShading.ahk">下载此脚本</a> &nbsp;| &nbsp;<a href="index.htm">其他示例脚本</a> &nbsp;| &nbsp;<a href="../AutoHotkey.htm">主页</a></p>

<pre class="NoIndent"><em>; Set the height of a rolled up window here.  The operating system
; probably won't allow the title bar to be hidden regardless of
; how low this number is:</em>
ws_MinHeight = 25

<em>; This line will unroll any rolled up windows if the script exits
; for any reason:</em>
OnExit, ExitSub
return  <em>; End of auto-execute section</em>

#z::  <em>; Change this line to pick a different hotkey.
; Below this point, no changes should be made unless you want to
; alter the script's basic functionality.
; Uncomment this next line if this subroutine is to be converted
; into a custom menu item rather than a hotkey.  The delay allows
; the active window that was deactivated by the displayed menu to
; become active again:
;Sleep, 200</em>
WinGet, ws_ID, ID, A
Loop, Parse, ws_IDList, |
{
    IfEqual, A_LoopField, %ws_ID%
    {
        <em>; Match found, so this window should be restored (unrolled):</em>
        StringTrimRight, ws_Height, ws_Window%ws_ID%, 0
        WinMove, ahk_id %ws_ID%,,,,, %ws_Height%
        StringReplace, ws_IDList, ws_IDList, |%ws_ID%
        return
    }
}
WinGetPos,,,, ws_Height, A
ws_Window%ws_ID% = %ws_Height%
WinMove, ahk_id %ws_ID%,,,,, %ws_MinHeight%
ws_IDList = %ws_IDList%|%ws_ID%
return

ExitSub:
Loop, Parse, ws_IDList, |
{
    if A_LoopField =  <em>; First field in list is normally blank.</em>
        continue      <em>; So skip it.</em>
    StringTrimRight, ws_Height, ws_Window%A_LoopField%, 0
    WinMove, ahk_id %A_LoopField%,,,,, %ws_Height%
}
ExitApp  <em>; Must do this for the OnExit subroutine to actually Exit the script.</em>
</pre>
</body>
</html>